package com.common.mqconfig;

import org.springframework.amqp.AmqpException;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessagePostProcessor;


/**
 * 这是带有过期时间的消息类
 */
public class ExpireMessage implements MessagePostProcessor {

    //过期时间属性 ttl  time to  live
    private String ttl;

    public ExpireMessage(String ttl){
        this.ttl = ttl;
    }

    //手动设置一个过期时间
    @Override
    public Message postProcessMessage(Message message) throws AmqpException {
        message.getMessageProperties().setExpiration(ttl);
        return message;
    }




}
